<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/supplier/orderaftersale/list" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='ddbh' /></label>
                        <div class="layui-input-inline">
                            <input type="text" name="order.orderNo" placeholder="<fmt:message key='qsrddmc' />" value="${params.order.orderNo}" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='shijian' /></label>
                        <div class="layui-input-inline" style="width:250px;">
                            <input type="text" id="feijin-begin-time" style="width:100px;" name="beginTime" placeholder="<fmt:message key='qrskssj' />" value="<c:if test='${params.beginTime !=null}'>${params.beginTime}</c:if>" autocomplete="off" class="layui-input"> -
                            <input type="text" id="feijin-end-time" style="width:100px;" name="endTime" placeholder="<fmt:message key='qsrjssj' />" value="<c:if test='${params.endTime !=null}'>${params.endTime}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zt' /></label>
                        <div class="layui-input-inline">
                            <select name="checkStatus">
                                <option value="0" <c:if test="${params.checkStatus eq 0}">selected</c:if>><fmt:message key='qxz' /></option>
                                <option value="1" <c:if test="${params.checkStatus eq 1}">selected </c:if>><fmt:message key='sqz' /></option>
                                <option value="2" <c:if test="${params.checkStatus eq 2}">selected</c:if>><fmt:message key='dmjjh' /></option>
                                <option value="3" <c:if test="${params.checkStatus eq 3}">selected</c:if>><fmt:message key='shbtg' /></option>
                                <option value="4" <c:if test="${params.checkStatus eq 4}">selected</c:if>><fmt:message key='dsjqs' /></option>
                                <option value="5" <c:if test="${params.checkStatus eq 5}">selected</c:if>><fmt:message key='sjqs' /></option>
                                <option value="6" <c:if test="${params.checkStatus eq 6}">selected</c:if>><fmt:message key='ywc' /></option>
                                <option value="7" <c:if test="${params.checkStatus eq 7}">selected</c:if>><fmt:message key='sjjjtk' /></option>
                            </select>
                        </div>
                    </div>

                    <!-- 需要排序的字段 -->
                    <%--<input type="hidden" class="feijin-orderby" name="orderByCreateTime" id="orderByCreateTimeParams" value="${params.orderByCreateTime}"/>--%>
                    <%--<input type="hidden" class="feijin-orderby" name="orderByPrice" id="orderByPriceParams" value="${params.orderByPrice}"/>--%>
                    <!-- 需要排序的字段 -->

                    <input type="hidden" name="checkStatus" value="${params.checkStatus}"/>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss' /></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <a href="${web_domain}/supplier/orderaftersale/exports?order.orderNo=${params.order.orderNo}&beginTime=${params.beginTime}&endTime=${params.endTime}&checkStatus=${params.checkStatus}" class="layui-btn layui-btn-sm" id="export"><i class="layui-icon">&#xe601;</i> <fmt:message key='dcdd' /></a>

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li
                            <c:if test="${params.status eq 0}">class="layui-this"</c:if> >
                        <a href="${web_domain}/supplier/orderaftersale/list"
                           <c:if test="${params.status eq 0}">style="color: rgb(0, 150, 136)"</c:if> ><fmt:message key='qb' /></a>
                    </li>
                    <li <c:if test="${params.status eq 1}">class="layui-this"</c:if>>
                        <a href="${web_domain}/supplier/orderaftersale/list?status=1" <c:if test="${params.status eq 1}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='sqz' /></a>
                    </li>
                    <li <c:if test="${params.status eq 2}">class="layui-this"</c:if>>
                        <a href="${web_domain}/supplier/orderaftersale/list?status=2" <c:if test="${params.status eq 2}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='tkcg' /></a>
                    </li>
                    <li <c:if test="${params.status eq 3}">class="layui-this"</c:if>>
                        <a href="${web_domain}/supplier/orderaftersale/list?status=3" <c:if test="${params.status eq 3}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='tksb' /></a>
                    </li>
                </ul>
            </div>


            <table class="layui-table" lay-size="sm">
                <thead>
                <th><fmt:message key='xh' /></th>
                <th><fmt:message key='ddbh' /></th>
                <th><fmt:message key='sqshijian' /></th>
                <th><fmt:message key='mjxx' /></th>
                <th><fmt:message key='tkje' /></th>
                <th><fmt:message key='tkyy' /></th>
                <th><fmt:message key='ddzt' /></th>
                <th><fmt:message key='tkzt' /></th>
                <th><fmt:message key='shouhzt' /></th>
                <th><fmt:message key='cz' /></th>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1 }</td>
                        <td>${item.order.orderNo}</td>
                        <td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        <td>
                            <p><fmt:message key='zh' />${item.member.username }</p>
                            <p><fmt:message key='shr' />：${item.order.deliveryName }</p>
                            <p><fmt:message key='ssshrsjh' />：${item.order.deliveryMobile }</p>
                        </td>
                        <td>
                            <fmt:formatNumber value="${item.refundPrice}" type="CURRENCY"/></td>
                        </td>
                        <td>
                                ${item.afterSaleReason}
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.order.status eq 1}"><fmt:message key='dfk' /></c:when>
                                <c:when test="${item.order.status eq 2}"><fmt:message key='dfh' /></c:when>
                                <c:when test="${item.order.status eq 3}"><fmt:message key='dsh' /></c:when>
                                <c:when test="${item.order.status eq 4}"><fmt:message key='dpj' /></c:when>
                                <c:when test="${item.order.status eq 5}"><b style="color:green;"><fmt:message key='jjwc' /></b></c:when>
                                <c:when test="${item.order.status eq 6}"><fmt:message key='yquxiao' /></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><fmt:message key='tkyy' /></c:when>
                                <c:when test="${item.status eq 2}"><fmt:message key='tkcg' /></c:when>
                                <c:when test="${item.status eq 3}"><fmt:message key='tksb' /></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.checkStatus eq 1}"><fmt:message key='sqz' /></c:when>
                                <c:when test="${item.checkStatus eq 2}"><fmt:message key='dmjjh' /></c:when>
                                <c:when test="${item.checkStatus eq 3}"><fmt:message key='shbtg' /></c:when>
                                <c:when test="${item.checkStatus eq 4}"><fmt:message key='dsjqs' /></c:when>
                                <c:when test="${item.checkStatus eq 5}"><fmt:message key='sjqs' /></c:when>
                                <c:when test="${item.checkStatus eq 6}"><fmt:message key='ywc' /></c:when>
                                <c:when test="${item.checkStatus eq 7}"><fmt:message key='sjjjtk' /></c:when>
                            </c:choose>
                        </td>

                        <td>
                            <div class="layui-btn-container">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ck' /></a>

                                <c:if test="${item.checkStatus eq 1 && item.order.status >= 3}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-check"><fmt:message key='shenhe' /></a>
                                </c:if>

                                <c:if test="${item.checkStatus eq 1 && item.order.status eq 2}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-refund"><fmt:message key='tk' /></a>
                                </c:if>

                                <c:if test="${item.checkStatus eq 4}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-signFor"><fmt:message key='qs' /></a>
                                </c:if>

                                <c:if test="${item.checkStatus eq 5}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-refund"><fmt:message key='tk' /></a>
                                </c:if>

                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['layer', 'form', 'laydate'], function () {
        var layer = layui.layer;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#feijin-begin-time'
        });

        laydate.render({
            elem: '#feijin-end-time'
        });

    });

    $(function () {

        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckxq' />'
                , content: '${web_domain}/supplier/orderaftersale/' + id + '/detail'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh' />']
            });
        });

        //编辑
        $(".feijin-check").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='shshdd' />'
                , content: '${web_domain}/supplier/orderaftersale/' + id + '/check'
                , maxmin: true
                , area: ['50%', '70%']
                , btn: ['<fmt:message key='qd' />', '<fmt:message key='qx' />']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

        //确认签收
        $(".feijin-signFor").click(function () {

            var id = $(this).attr("data-id");

            layer.confirm('<fmt:message key='qrqsm' />', function (index) {

                $.ajax({
                    url: "${web_domain}/supplier/orderaftersale/signFor",
                    dataType: "json",
                    type: "post",
                    data: {
                        "_method": "put",
                        "id": id
                    },
                    success: function (result) {
                        if (result.status) {
                            location.reload();
                        } else {
                            layer.msg(result.message);
                            layer.close(index);
                        }
                    }
                });
            });
        });

        //退款
        $(".feijin-refund").click(function () {

            var id = $(this).attr("data-id");

            layer.confirm('<fmt:message key='qryltkm' />', function (index) {

                var load = layer.load(10);

                $.ajax({
                    url: "${web_domain}/supplier/orderaftersale/refund",
                    dataType: "json",
                    type: "post",
                    data: {
                        "_method": "put",
                        "id": id
                    },
                    success: function (result) {
                        layer.close(load);

                        if (result.status) {
                            location.reload();
                        } else {
                            layer.msg(result.message);
                            layer.close(index);
                        }
                    }
                });
            });
        });

        <%--//按时间排序--%>
        <%--$("#orderByCreateTime").click(function () {--%>
        <%--$(".feijin-orderby").attr("value", "");--%>
        <%--var orderBy = "${params.orderByCreateTime}";--%>

        <%--if (orderBy == "asc") {--%>
        <%--$("#orderByCreateTimeParams").attr("value", "");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>

        <%--if (orderBy == "desc") {--%>
        <%--$("#orderByCreateTimeParams").attr("value", "asc");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>

        <%--if (orderBy == "") {--%>
        <%--$("#orderByCreateTimeParams").attr("value", "desc");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>
        <%--});--%>

        <%--//按余额排序--%>
        <%--$("#orderByPrice").click(function () {--%>
        <%--$(".feijin-orderby").attr("value", "");--%>
        <%--var orderBy = "${params.orderByPrice}";--%>

        <%--if (orderBy == "asc") {--%>
        <%--$("#orderByPriceParams").attr("value", "");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>

        <%--if (orderBy == "desc") {--%>
        <%--$("#orderByPriceParams").attr("value", "asc");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>

        <%--if (orderBy == "") {--%>
        <%--$("#orderByPriceParams").attr("value", "desc");--%>
        <%--$("#search").click();--%>
        <%--return;--%>
        <%--}--%>

        <%--});--%>


    });
</script>
</body>
</fmt:bundle>
</html>
